package com.acwebsitedesign.uRateDrugs.domain;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.Errors;

public class AccountValidator {

	@Autowired
	AccountService accountService;

	@SuppressWarnings("unchecked")
	public boolean supports(Class clazz) {
		return Account.class.equals(clazz);
	}

	public void validate(Object object, Errors e) {
		Account account = (Account) object;
		String agreeToTerms = account.getAgreeToTerms();

		if (agreeToTerms == null ) {
			e.rejectValue("agreeToTerms", "agreeToTerms.invalid");
		}
	}
}
